# @Time : 2021/4/9 9:41
# @Author : Fioman 
# @Phone : 13149920693
"""
设备的状态类
"""


class CbjZmcStates(object):
    """
    裁切机的状态类
    """

    def __init__(self):
        self.connectState = -1
        self.online = False
        self.rs = False
        self.run = False


class CamZmcStates(object):
    """
    拍照控制器的状态类
    """

    def __init__(self):
        self.connectState = -1
        self.online = False
        self.rs = False
        self.run = False


class BigCutterZmcStates(object):
    """
    前铡刀控制器的状态类.
    """

    def __init__(self):
        self.connectState = -1
        self.online = False
        self.rs = False
        self.run = False

class SmallCutterZmcStates(object):
    """
    前铡刀控制器的状态类.
    """
    
    def __init__(self):
        self.connectState = -1
        self.online = False
        self.rs = False
        self.run = False


class DeviceStates(object):
    def __init__(self):
        self.camZmcStates = CamZmcStates()
        self.cbjZmcStates = CbjZmcStates()
        self.bigCutterZmcStates = BigCutterZmcStates()
        self.smallCutterZmcStates = SmallCutterZmcStates()
        self.mainAlarmInfo = ""  # 主控制器的报警信息
        self.mainAlarmInfoVisible = False
        self.cameraGroupStates = [False, False, False, False, False, False]
        self.camZmcIsRs = False
        self.cbjZmcIsRs = False
        self.bigCutterZmcIsRs = False
        self.smallCutterZmcIsRs = False
        self.camZmcIsRun = False
        self.cbjZmcIsRun = False
        self.bigCutterZmcIsRun = False
        self.smallCutterZmcIsRun = False
        self.leftCamIsOnline = False
        self.rightCamIsOnline = False
        self.cutterCam1IsOnline = False
        self.cutterCam2IsOnline = False
        self.workStopFlag = True
        self.operaProcedureStart = True
        self.camZmcIOStates = []
        self.cbjZmcIOStates = []
        self.bigCutterZmcIOInfo = []
        self.smallCutterZmcIOInfo = []
        self.camZmcOPStates = []
        self.cbjZmcOPStates = []
        self.bigCutterZmcOPStates = []
        self.smallCutterZmcOPStates = []

    def pack_state_to_dict(self):
        """
        将状态信息封装为字典,好发送给前端
        :return:
        """
        res = {
            "camZmcStates": {
                "online": self.camZmcStates.online,
                "rs": self.camZmcStates.rs,
                "run": self.camZmcStates.run
            },
            "cbjZmcStates": {
                "online": self.cbjZmcStates.online,
                "rs": self.cbjZmcStates.rs,
                "run": self.cbjZmcStates.run,
            },
            "bigCutterZmcStates": {
                "online": self.bigCutterZmcStates.online,
                "rs": self.bigCutterZmcStates.rs,
                "run": self.bigCutterZmcStates.run,
            },
            "smallCutterZmcStates": {
                "online": self.smallCutterZmcStates.online,
                "rs": self.smallCutterZmcStates.rs,
                "run": self.smallCutterZmcStates.run,
            },
            "mainAlarmInfo": self.mainAlarmInfo,
            "mainAlarmInfoVisible": self.mainAlarmInfoVisible,
            "cameraGroupStates": self.cameraGroupStates,
            "autoState": not self.workStopFlag,
            "operaProcedureStart": self.operaProcedureStart,
            "camZmcIOStates": self.camZmcIOStates,
            "cbjZmcIOStates": self.cbjZmcIOStates,
            "bigCutterZmcIOInfo": self.bigCutterZmcIOInfo,
            "smallCutterZmcIOInfo": self.smallCutterZmcIOInfo,
            "camZmcOPStates": self.camZmcOPStates,
            "cbjZmcOPStates": self.cbjZmcOPStates,
            "bigCutterZmcOPStates": self.bigCutterZmcOPStates,
            "smallCutterZmcOPStates": self.smallCutterZmcOPStates
        }
        return res
